home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 119_01.zip / COMMDWS.C < prev    next >
Text File  |  1993-06-16  |  2KB  |  69 lines

  1.  
  2. /*    CommX.C - Additional Commands for Mince.
  3.  
  4.     Dave W. Smith, 450 N. Mathilda, #O-103, Sunnyvale, CA 94086
  5.  
  6.     Caveat:    Adding these to Mince requires that you recompile the
  7.      sources  with -e8100, and link with LMince, LUtil, etc. (See
  8.          the section 'Compiling and Linking Mince' (p. 1-16 of the
  9.          Program Logic Manual) for more information).
  10.  
  11.     The changes to Bindings.C are left as an exercise to the user.  */
  12.  
  13. #include "mince.gbl"        /* pick up global definitions */
  14.  
  15. MToglC()    /* (C-^)  Toggle the case of a  character */
  16. {
  17.   tmp = Buff();
  18.   if (tmp >= 'a' && tmp <= 'z') tmp = tmp - 040;
  19.   else if ( tmp >= 'A' && tmp <= 'Z') tmp = tmp + 040;
  20.   if ( tmp != Buff()){
  21.     BDelete(1);
  22.     BInsert(tmp);
  23.   } else BMove(1);
  24. }
  25.  
  26. /*  Routine to search for a matching delimiter, skipping over pairs of 
  27.     delimiters.  (Find me my open paren, boss.) Generalized somewhat
  28.     to work with a vareity of delimiters.                               */
  29.  
  30. MDMatch()    /* M-(, M-), M-{, M-}, etc. */
  31. {
  32.   int Dir, Delim, MDelim, Count;
  33.   tmark = BCreMrk();
  34.   Delim = cmnd & 0177;
  35.   if      ( Delim == '(' ) {MDelim = ')' ; Dir = BACKWARD; }  
  36.   else if ( Delim == ')' ) {MDelim = '(' ; Dir = FORWARD;  }  
  37.   else if ( Delim == '{' ) {MDelim = '}' ; Dir = BACKWARD; }  
  38.   else if ( Delim == '}' ) {MDelim = '{' ; Dir = FORWARD;  }  
  39.   else if ( Delim == '[' ) {MDelim = ']' ; Dir = BACKWARD; }  
  40.   else if ( Delim == ']' ) {MDelim = '[' ; Dir = FORWARD;  }  
  41.   Count = (Buff() == MDelim ) ? 1 : -1;
  42.   while ( 1 ) {
  43.     TKbChk();
  44.     BMove( Dir ? 1 : -1);
  45.     if (Dir && BIsEnd()) break;
  46.     if ( Buff() == MDelim ) Count = (Count < 0) ? 2 : Count + 1;
  47.     else if ( Buff () == Delim ) Count = (Count < 0) ? 0 : Count - 1;
  48.     if ( !Dir && BIsStart()) break;
  49.     if ( !Count ) break;
  50.   }
  51.   if ( Count ) {
  52.     Echo( "No Match" );
  53.     BPntToMrk( tmark );
  54.     arg = 0; 
  55.     }
  56.   BKillMrk( tmark );
  57. }
  58.  
  59. MFini()        /* (C-X C-F) Write File and Exit */
  60. {
  61.     MFileSave();
  62.     MExit();
  63. }
  64.  
  65. /* End of CommX.C  - Additional Commands for Mince.   */
  66.  
  67. tmark = BCreMrk();
  68.   Delim = cmnd & 0177;
  69.   if      ( Delim == '(' ) {MDelim = ')' ; Di